tools/xenconsole: fix Segmentation fault
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 8 Feb 2010 08:50:03 +0000 (08:50 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 8 Feb 2010 08:50:03 +0000 (08:50 +0000)
Segmentation fault occurs if DOMID isn't specified.
Some check be added to output error message in this situation.

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
tools/console/client/main.c

index 63e729acabba74a00de711877b4927a12fc254be..840f08eec6b6e2fef1f957e84e92cae304572a96 100644 (file)
@@ -287,7 +287,13 @@ int main(int argc, char **argv)
                        exit(EINVAL);
                }
        }
-       
+
+       if (optind >= argc) {
+               fprintf(stderr, "DOMID should be specified\n");
+               fprintf(stderr, "Try `%s --help' for more information.\n",
+                       argv[0]);
+               exit(EINVAL);
+       }
        domid = strtol(argv[optind], &end, 10);
        if (end && *end) {
                fprintf(stderr, "Invalid DOMID `%s'\n", argv[optind]);